<template>
    <div>
        <div class="header">
            商品分类
            <i class="iconfont icon-sousuo"></i>
        </div>
        <div class="cotainer">
            <div class="content_left">
                <ul class="list-left">
                    <li v-for="(item,index) in list" :key="index" :class="{select:con==index}" @click="cons(index)">{{item.sName}}</li>
                </ul>
            </div>
            <div class="list-right">
                <div>
                    <div class="right-top">
                        <span v-if="list.length>0">{{list[con].comment}}</span>
                        <i class="iconfont icon-right"></i>
                    </div>
                    <ul class="right-bottom" v-if="list.length>0">
                        <li v-for="(i,j) in list[con].stationSaleTypeModels" :key="j">{{i.sName}}</li>
                    </ul>
                </div>
                <div class="brand">
                    <div class="brand-title">
                        <i>-</i>
                        <span>热门品牌</span>
                        <i>-</i>
                    </div>
                    <ul class="brand-list">
                        <li v-for="(item,index) in lists" :key="index">
                            <div class="img-wrap">
                                <img :src="item.logoUrl" alt="">
                            </div>
                            <p>{{item.name}}</p>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>    
</template>
<script>
import BScrool from 'better-scroll';
import qs from 'qs'
export default {
    data(){
        return{
            con:0,
            list:[],
            lists:[]
        }
    },
    methods:{
        cons(index){
            this.con=index
            this.getBrandInfo(this.$store.state.userInfo.id);
        },
        getStationId(){
            let stationId=this.$store.state.stationId||22
            let headers;
            if(this.$store.state.token){
                 headers={
                token:this.$store.state.token,
                userid:this.$store.state.userInfo.id
                }
            }else{
                headers={

                }
            }
            this.$http.post('https://web-gateway.newbeescm.com/b2b-app-web/getSortInfoByStationIdV2/'+stationId,{
                headers
            })
            .then(res=>{
                if(res.data.status.statusCode===0){
                    console.log(res)
                    this.list=res.data.result.list
                    this.getBrandInfo();
                }
            })
            .catch(err=>{
                console.log(err)
            })
        },
        getBrandInfo(con){
            let headers;
            if(this.$store.state.token){
                 headers={
                token:this.$store.state.token,
                userid:this.$store.state.userInfo.id
                }
            }else{
                headers={}
            }
            this.$http.post('https://web-gateway.newbeescm.com/b2b-app-web/getBrandInfo',{},
            {
                headers,    
                params:{
                    firstSaleTypeId:this.list[this.con].id,
                    num:100,
                    stationId:this.$store.state.stationId||22
                }
            })
            .then(res=>{
                if(res.data.status.statusCode===0){
                    console.log(res)
                    this.lists=res.data.result
                }
            })
            .catch(err=>{
                console.log(err)
            })
        }
    },
    mounted(){
        let content_left=document.querySelector('.content_left');
        let sss=new BScrool(content_left, {
            click: true
        });
        // let content_right=document.querySelector('.content_right');
        // let con=new BScrool(content_right,{
        //     click: true
        // });
    },
    created(){
        this.getStationId()
    }
}
</script>
<style scoped lang="scss">
.header{
    height: 0.44rem;
    line-height: 0.44rem;
    font-size: 0.18rem;
    color: #030303;
    text-align: center;
    position: relative;
    .icon-sousuo{
        font-size: 0.18rem;
        position: absolute;
        right: 0.14rem;
        bottom: 0;
        font-weight: bolder;
        color: #ccc;
    }
}
.header::after{
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    background: #e4e4e4;
    transform: scale(1,0.5);
}
.cotainer{
    display: flex;
    width: 100%;
    position: absolute;
    top: 0.44rem;
    bottom: 0.49rem;
    overflow: hidden;
    .list-left{
        width: 25%;
        background: #fff;
        text-align: center;
        li{
            width: 0.96rem;
            height: 0.5rem;
            background: #f2f2f2;
            line-height: 0.5rem;
            font-size: 0.14rem;
            color: #666;
            margin-bottom: 1px;
        }
        .select{
            color: #DD3333;
            background: #fff;
            border-left: 2px solid #DD3333;
        }
    }
    .list-right{
        width: 75%;
        padding: 0.14rem 0.15rem 0 0.14rem;
        .right-top{
            padding-left: 0.14rem;
            padding-right: 0.11rem;
            height: 0.3rem;
            background: #FFF8F2;
            border-radius: 2px;
            line-height: 0.3rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: #EE793E;
            font-size: 0.12rem;
            .icon-right{
                font-size: 0.12rem;
            }
        }
        .right-bottom{
            margin-top: 0.15rem;
            margin-bottom: 0.02rem;
            display: flex;
            flex-wrap: wrap;
            li{
                font-size: 0.12rem;
                color: #333;
                width: 0.6rem;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                line-height: 0.12rem;
                margin-right: 0.1rem;
                margin-bottom: 0.18rem;
            }
        }
        .brand{
            margin-top:0.17rem;
            .brand-title{
                text-align: center;
                margin-bottom: 0.13rem;
                i{
                    color: #ccc;
                    margin-right: 0.05rem;
                }
                span{
                    font-size: 0.12rem;
                    color: #000;
                }
            }
            .brand-list{
                display: flex;
                justify-content: space-between;
                flex-wrap: wrap;
                align-items: center;
                li{
                    .img-wrap{
                        width: 0.75rem;
                        height: 0.75rem;
                        border: 1px solid #eee;
                        border-radius: 2px;
                        img{
                            width: 0.66rem;
                            height: 0.66rem;
                            margin: 0.06rem 0.06rem 0.05rem 0.05rem;
                        }
                    }
                    p{
                        font-size: 0.12rem;
                        color: #999;
                        text-align: center;
                        line-height: 0.12rem;
                        margin: 0.06rem 0 0.13rem;
                        // width: 0.6rem;
                        overflow: hidden;
                        text-overflow:ellipsis;
                        white-space: nowrap; 
                    }
                }
            }
        }
    }

}
</style>
